package com.zh.mp.demo.modules.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zh.mp.demo.modules.order.entity.Log;
import com.zh.mp.demo.modules.order.entity.Orders;
import com.zh.mp.demo.modules.order.mapper.LogMapper;
import com.zh.mp.demo.modules.order.service.ILogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zh.mp.demo.modules.order.service.IOrderService;
import jdk.nashorn.internal.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 订单日志 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-20
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements ILogService {
    @Autowired
    private IOrderService iOrderService;

    @Override
    //@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public void saveLog(Log log) {
        this.baseMapper.insert(log);
        //此处查询下订单 是否可以查询到
        Orders orders = this.iOrderService.getOne(new LambdaQueryWrapper<Orders>().eq(Orders::getOrderCode,log.getOrderCode()));
        System.out.println("日志事物下查询到订单:"+ orders);
    }
}
